home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / Ant Movie Catalog 3.5.0.2 / amc_install.exe / {app} / Scripts / e-Pipoca (Br).ifs < prev    next >
Text File  |  2005-05-24  |  5KB  |  158 lines

  1. (***************************************************
  2.  
  3. Ant Movie Catalog importation script
  4. www.antp.be/software/moviecatalog/
  5.  
  6. [Infos]
  7. Authors=O Guardiπo
  8. Title=e-Pipoca
  9. Description=Movie importation script for e-Pipoca
  10. Site=www.epipoca.com.br
  11. Language=PT
  12. Version=1.1 (24 Maio 2005)
  13. Requires=3.5.0
  14. Comments=Caso detectem erros coloquem-nos no meu site: <link>www.guardiao.pt.vu</link> ou enviem para o email: bruno_mga@hotmail.com
  15. License=This program is free software; you can redistribute it and/or modify it under the  terms of the GNU General Public License as published by the Free Software Foundation;  either version 2 of the License, or (at your option) any later version. |
  16. GetInfo=1
  17.  
  18. [Options]
  19.  
  20. ***************************************************)
  21.  
  22. program EPipoca;
  23. uses
  24.   StringUtils1;
  25.   
  26. var
  27.   MovieName: string;
  28.   MovieURL: string;
  29.   
  30. function HTMLRemove(Value: String): String;
  31. begin
  32.   HTMLDecode(Value);
  33.   HTMLRemoveTags(Value);
  34.   Value := Trim(Value);
  35.   result := Value;
  36. end;
  37.  
  38. procedure AnalyzeFilmPage(Address: String);
  39. var
  40.   Page : TStringList;
  41.   nome_orig, ano, value : string;
  42.   LineNr, BeginPos, EndPos: Integer;
  43. begin
  44.   Page := TStringList.Create;
  45.   Page.Text := GetPage(Address);
  46.   SetField(fieldURL, Address);
  47.   value:=Page.Text;
  48.  
  49.   BeginPos:= pos('</font><br>(<i>',value)+15;
  50.   value:=Copy(value,BeginPos,Length(value));
  51.   EndPos := pos('</i>', value);
  52.   nome_orig:=copy(value,1,EndPos-1);
  53.   SetField(fieldOriginalTitle, nome_orig);
  54.  
  55.   BeginPos:=Pos(')',value);
  56.   ano:=copy(value,BeginPos-4,4);
  57.   SetField(fieldYear, ano);
  58.   
  59.   if Copy(value,BeginPos-6,1) =',' then
  60.   begin
  61.     value:=Copy(value,EndPos+6,BeginPos-EndPos-12);
  62.     SetField(fieldCountry, value);
  63.   end;
  64.  
  65.   value := TextBetween(Page.Text,'<b>Duraτπo</b>: ',' min<br>');
  66.   SetField(fieldLength,value);
  67.   
  68.   LineNr := FindLine('<b>Distribuidora</b>',Page,0);
  69.   if LineNr<>-1 then
  70.   begin
  71.     value := Page.GetString(LineNr+2);
  72.     EndPos:=Pos('<br>',value);
  73.     value :=Copy(value,1,EndPos-1);
  74.     SetField(fieldProducer,value);
  75.   end;
  76.  
  77.   LineNr := FindLine('<td valign="top" width="100%">', Page, 0)+1;
  78.   if LineNr<>0 then
  79.   begin
  80.     value := Page.GetString(LineNr);
  81.     BeginPos := pos('<font size="3"><b>', value)+18;
  82.     EndPos := pos('</b>',value);
  83.     value:=Copy(value,1,EndPos);
  84.     value:=HTMLRemove(value);
  85.     SetField(fieldTranslatedTitle, value);
  86.   end
  87.  
  88.   value := TextBetween(Page.Text,'<b>GΩnero</b>: ', '<br>');
  89.   SetField(fieldCategory, value);
  90.  
  91.   value := TextBetween(Page.Text,'<b>Diretor(es)</b>:','<br>');
  92.   value:=HTMLRemove(value);
  93.   value:=copy(value,5,length(value));
  94.   SetField(fieldDirector, value);
  95.  
  96.   value := TextBetween(Page.Text,'<b>Elenco:</b>','<b>mais...</b>');
  97.   value:=HTMLRemove(value);
  98.   value:=copy(value,5,length(value)-7);
  99.   SetField(fieldActors, value);
  100.   
  101.   value := TextBetween(Page.Text,'<b>Sinopse</b><br>','</td>');
  102.   SetField(fieldDescription, value);
  103.  
  104.   value := TextBetween(Page.Text,'<img src="/images/filmes/capa','"');
  105.   value:='http://epipoca.cidadeinternet.com.br/images/filmes/capa'+value;
  106.   GetPicture(Value);
  107.   
  108.   value := TextBetween(Page.Text,'<font size="3"><b> ','</b>');
  109.   SetField(fieldRating, value);
  110. end;
  111.  
  112. procedure AnalyzePage(Address: string);
  113. var
  114.   Page: TStringList;
  115.   LineNr, StartPos, EndPos: Integer;
  116.   Line: string;
  117.   BeginPos,x:integer;
  118.   MovieAddress, findMovieName,linedown : string;
  119.   url, nome_filme:string;
  120. begin
  121.   PickTreeClear;
  122.   Page := TStringList.Create;
  123.   Page.Text := GetPage(Address);
  124.   if (pos('<br>Nenhuma ocorrΩncia com a palavra', Page.Text)=0) then
  125.   begin
  126.     repeat
  127.      LineNr := FindLine('<b><a href="/filmes_zoom.cfm?id=', Page, LineNr+1);
  128.       Line := Page.GetString(LineNr);
  129.  
  130.  
  131.         BeginPos:= Pos('<b><a href="/filmes_zoom.cfm?id=', line);
  132.         if BeginPos=0 then break;
  133.  
  134.         line:=Copy(line,BeginPos+31,length(line));
  135.         EndPos:=Pos('">',line)-1;
  136.         url:=Copy(line,0,EndPos);
  137.         line:=Copy(line,EndPos+2,length(line));
  138.         BeginPos:=Pos('">',line)+2;
  139.         EndPos:=Pos('</font>',line);
  140.         line:=Copy(line,BeginPos,EndPos-BeginPos);
  141.         PickTreeAdd(line, 'http://epipoca.cidadeinternet.com.br/filmes_zoom.cfm?id'+url);
  142.     until (line='');
  143.  
  144.     if PickTreeExec(Address) then
  145.       AnalyzeFilmPage(Address);
  146.     Page.Free;
  147.   end
  148.   else
  149.   showmessage('Filme nπo encontrado');
  150. end;
  151. begin
  152.   PickListClear;
  153.   MovieName := GetField(fieldOriginalTitle);
  154.   if Input('Importar do e-Pipocat', 'Escreva o nome do filme:', MovieName) then
  155.   AnalyzePage('http://epipoca.cidadeinternet.com.br/search/index.cfm?busca='+URLencode(MovieName));
  156. end.
  157.  
  158.